// this指针与链式编程思想
#include <iostream>
using namespace std;
class Student {

};
class Person {
public:
    int m_age;
    // 初始化列表
    Person(int age): m_age(age) {}

    // 返回值
    Person addAge1(Person& p) {
        this->m_age += p.m_age;
        return (*this);
    }

    // 返回引用
    Person& addAge2(Person& p) {
        this->m_age += p.m_age;
        return (*this);
    }


};
int main(void) {
    Student s1;
    // 空对象大小为1字节
    cout << "null object size: " << sizeof(s1) << endl;
    Person p1(10);
    Person p2(20);
    p1.addAge1(p2);
    cout << "p1.m_age= " << p1.m_age << endl; // 运行后p1为30
    p1.addAge1(p2).addAge1(p2).addAge1(p2);
    cout << "p1.m_age= " << p1.m_age << endl; // 运行后p1为50
    // 链式编程思想
    p1.addAge2(p2).addAge2(p2).addAge2(p2);
    cout << "p1.m_age= " << p1.m_age << endl; // 运行后p1为110

    return 0;
}